<template>
	<view class="page" :style="{minHeight:windowHeight+'px'}">
		<!-- <view class="show">
			<view class="item" v-for="n in 1">
				<view @click="gotoPage('/pages/user/orderRecord/orderDetail/orderDetail')">
					<view>
						<view class="item_head">
							<view class="site">
								永州林灵→东莞麻涌
							</view>
							<view class="day">三天</view>
						</view>
						<view class="site_num">
							<text>10座</text>
							<text class="foot_line">|</text>
							<text>10座</text>
						</view>
						<view class="company">
							<image class="company_image" src="../../../../static/app/logo.png"></image>
							<text>桂林大聪网络有限公司</text>
						</view>
						<view class="foot">
							<text>订单号：1111111111111</text>
							<text class="price">&yen 3900</text>
						</view>
					</view>
					<view class="line"></view>
					<view>
						<view class="car-wrap">
							<view class="car-list">
								<view class="car-item" v-for="(item,index) of car">
									<view class="car-pic">
										<image :src="item.car_info3" mode=""></image>
									</view>
									<view class="car-info">
										<view class="car-item-head">
											<view>{{item.type_name}}</view>
										</view>
										<view class="car-number">{{item.car_number}}</view>
										<view class="car-item-bottom">
											<text>司机：{{item.drivername}}</text>
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="line" v-if="select == 2"></view>
					</view>
					<view class="arrange">
						<view @click="gotoPage('/pages/user/orderRecord/arrange/arrange')">安排司机</view>
						<view @click="orderDetail(type,order_id)">安排车辆</view>
					</view>
				</view>
			</view>
		</view> -->
		<view class="show" v-if="orderinfo != ''">
			<view class="item">
				<view>
					<view class="item_head">
						<view class="site">
							<view class="item-con-begin-address" >
								<view class="dot dot-begin"></view>
								<view>{{orderinfo.star_address.b_name}}</view>						
							</view>
							<view class="item-con-begin-address">
								<view class="dot"></view>
								<view>{{orderinfo.end_address.d_name}}</view>						
							</view>
							<!-- {{orderinfo.star_address.b_name}}→{{orderinfo.end_address.d_name}} -->
						</view>
						<!-- <view class="day">{{orderinfo.days}}</view> -->
						<view class="userCar">用车{{orderinfo.days}}天</view>
					</view>
					<view class="site_num">
						<text>{{orderinfo.car_number}}车</text>
						<text class="foot_line">|</text>
						<text>{{orderinfo.passenger}}人</text>
					</view>
					<view class="company">
						<image class="company_image" :src="orderinfo.user.avatarUrl"></image>
						<!-- <text>{{orderinfo.user.nickName}}</text> -->
						<view class="company_image-name" v-if="orderinfo.attestation.types==1" @click="phoneCall(orderinfo.attestation.phone)">
							<text>{{orderinfo.attestation.phone}}</text>
						</view>
						<view class="user-name" v-else @click="phoneCall(orderinfo.attestation.person_name)">
							<text>{{orderinfo.attestation.person_phone}}</text>
						</view>
					</view>
					<view class="foot">
						<text>订单号：{{orderinfo.ordernum}}</text>
						<text class="price">&yen {{orderinfo.price}}</text>
					</view>
				</view>
				<view class="line" v-if="orderinfo.carplan.length==0"></view>
				<view v-if="orderinfo.carplan.length!=0">
					<view class="car-wrap">
						<view class="car-list">
							<view class="car-item" v-for="(item,index) of orderinfo.carplan" :key="index">
								<view class="car-botop">
									<view class="car-pic">
										<image :src="item.car_info4" mode=""></image>
									</view>
									<view class="car-info">
										<view class="car-item-head">
											<view>{{item.type_name}}</view>
										</view>
										<view class="car-number"><text>车牌号：</text>{{item.car_number}}</view>
										<view class="car-item-bottom">
											<view>司机电话：<text @click="phoneCall(item.driver_phone)"
													style="color: #0368FF;font-size: 30rpx;">{{item.driver_phone}}</text>
											</view>												
										</view>
										<image @click="delCar(item.id)" class="car-item-bottom-del" src="../../../../static/delete.png"></image>
									</view>
									
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="arrange">
					<!-- <view @click="gotoPage('/pages/user/orderRecord/arrange/arrange')">安排司机</view> -->
					<view @click="orderDetail(order_id)">安排车辆</view>
				</view>
			</view>
		</view>
		<!-- 没有记录 -->
		<view class="d-c-c p30" v-if="orderinfo.length == 0">
			<text class="cont">亲，暂无相关记录哦</text>
		</view>
		<!-- <uni-load-more v-else :loadingType="loadingType"></uni-load-more> -->
		<!-- </scroll-view> -->
	</view>
</template>

<script>
	import uniLoadMore from '@/components/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				loadding: false,
				listData: [],
				idx: 0,
				aa: 17,
				car: '',
				/*可滚动视图区域高度*/
				windowHeight: 0,
				/*当前选中的类别*/
				type_active: 0,
				select: '',
				order_id: '', //订单Id
				type: '', //订单类型
				orderinfo: []
			};
		},
		onPullDownRefresh() {
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onLoad(e) {
			//console.log(e.car_id);
			//console.log(e)

			//this.car_id=e.car_id;
			if (e.select == 2) {
				this.select = e.select;
				this.order_id = e.id;
				this.type = e.type;
				//this.getCarData();
				this.getDatainfo();
			}
			//this.getDatainfo();
			uni.getSystemInfo({
				success: (res) => {
					this.windowHeight = res.windowHeight;
				}
			});
			//console.log(this.windowHeight)
		},
		computed: {
			/*加载中状态*/
			loadingType() {
				if (this.loadding) {
					return 1;
				} else {
					if (this.listData.length != 0) {
						return 2;
					} else {
						return 0;
					}
				}
			}
		},
		onShow() {
			//this.getDatainfo();
		},
		methods: {
			phoneCall(phone) {
				//console.log(phone)
				let self = this;
				uni.makePhoneCall({
					phoneNumber: phone
				});
			},
			// gotoPlan() {
			// 	console.log(this.type, this.id);
			// 	uni.navigateTo({
			// 		url: '/pages/user/orderRecord/arrange_car/arrange_car?select=1&&type=' + this.type + '&&id=' +
			// 			this.id
			// 	})
			// },
			delCar(id){
				let self = this;
				uni.showModal({
					title:'温馨提示',
					content:'是否要删除此车辆',
					success(res) {
						if(res.confirm){
							uni.showLoading({
								title:'删除中'
							});
							self._post('order.CarOrder/del_plan_car',{id:id},function(res){
								if(res.code == 1){
									uni.showToast({
										title:'删除成功',
										duration:2000,
										icon:"none"
										
									})
									self.getDatainfo();
								}else{
									uni.showToast({
										title:'删除失败',
										duration:2000,
										icon:"none"
										
									})
								}
								
							})
						}else{
							return;
						}
					}
				})
				console.log(id)
			},
			orderDetail(id) {
				//console.log(type);
				console.log(id);
				uni.navigateTo({
					url: '/pages/user/orderRecord/orderDetail/orderDetail?select=1&&id=' +
						id
				})
			},
			/*跳转页面*/
			gotoPage(path) {
				let self = this;
				if (path.startsWith('/')) {
					uni.navigateTo({
						url: path
					});
				} else {
					self[path]();
				}
			},
			// // /*获取车辆数据*/
			// getCarData() {
			// 	let self = this;
			// 	uni.showLoading({
			// 		title: '加载中'
			// 	});
			// 	self._get('user.index/my_car', {

			// 		},
			// 		function(res) {
			// 			self.car = res.data.car;
			// 			console.log(res);
			// 			// self.loadding = false;
			// 			uni.hideLoading();
			// 		});
			// },
			/*获取数据*/
			getDatainfo() {
				let self = this;
				//console.log(self.order_id)
				uni.showLoading({
					title: '加载中'
				});
				self._post('order.CarOrder/get_details', {
						id: self.order_id,
					},
					function(res) {
						self.orderinfo = res.data.info;
						//console.log(res.data.orderinfo);
						//self.loadding = false;
						uni.hideLoading();
					});
			},
			/*跳转详情*/
			gotoDetail(e) {
				uni.navigateTo({
					url: '/pages/user/orderRecord/detail/detail?type=' + e
				});
			}

			/* 切换导航条 */
			// tabClick(item) {
			// 	this.idx = item.id;
			// },
		}
	}
</script>

<style lang="scss">
	@import 'detail.scss';
</style>
